import {ref, reactive} from 'vue'
import {defineStore} from 'pinia'
import type {Menu} from '@/router'

export interface UserInfo {
    Id: number;
    user_name: string;
    avatar?: string;
    account: string;
    type: '1' | '0';
    token: string;
}

export const useUserStore = defineStore('user', () => {
    const userInfo = reactive<UserInfo>({
        "Id": 0,
        "user_name": "",
        "avatar": "",
        "account": '',
        "type": "0",
        "token": "",
    });
    const setUserInfo = (obj: object) => {
       return Object.assign(userInfo, obj)
    }
    return {
        userInfo,
        setUserInfo
    }
})

export const useMenuStore = defineStore('menu', () => {
    const menu = ref<Menu[]>([]);
    const setMenu = (menuList: Menu[]) => {
        menu.value = menuList;
    }
    return {
        menu,
        setMenu
    }
})